home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
vs
/
browser
/
cpn11b1.exe
/
DATA.Z
/
sphere.java
< prev
next >
Wrap
Text File
|
1996-11-06
|
1KB
|
67 lines
/*
* File : sphere.java (Script for Community Place)
* Version : 2.0- 1996.09.11
* Auther : cori co.
*
* Copyright(C) 1996 Sony Corporation. All rights reserved.
*/
import vrml.*;
import vrml.field.*;
import vrml.node.*;
import java.util.*;
//import vs.*;
/* This is a sample script for event handler.*/
public class sphere extends Script {
SFColor SphereDiffuseColor;
boolean SphereColorFlg = false;
/*
* Initialize
*/
public void initialize() {
SphereDiffuseColor = (SFColor)getEventOut( "SphereDiffuseColor" );
}
/*
* eventIn
*/
public void processEvent( Event e ) {
String name = e.getName();
if ( name.equals( "SphereClicked" )) {
SphereClicked( (ConstSFBool)e.getValue() );
}
}
/*
* Clicked on the sphere
*/
void SphereClicked( ConstSFBool state ) {
float col[] = new float[3];
if ( !state.getValue() ) { /* != mouseDown */
if ( SphereColorFlg == false ) {
col[0] = 1.0f;
col[1] = 0.0f;
col[2] = 0.0f;
SphereColorFlg = true;
} else {
col[0] = 0.0f;
col[1] = 0.8f;
col[2] = 0.8f;
SphereColorFlg = false;
}
SphereDiffuseColor.setValue( col );
}
}
}